﻿using System;
using System.Threading;
using DotNet.Utilities;

namespace ConsoleApp
{
    public class Singlethread
    {
        private string _logFilePath = AppDomain.CurrentDomain.BaseDirectory + @"\log.txt";

        public void Start()
        {
            Thread t = new Thread(Processor);
            t.Name = "Single Thread";
            t.Start();
        }

        private void Processor()
        {
            //var list = CommentDal.GetOneRowComment();
            var list = CommentDal.GetCommentList();
            if (list != null)
            {
                foreach (var obj in list)
                {
                    //Console.WriteLine(string.Format("{0}  {1}\t{2}", DateTime.Now, Thread.CurrentThread.Name, obj.Content));
                    FileOperate.WriteFile(_logFilePath,
                        string.Format("{0}:  {1}\t{2}", DateTime.Now, Thread.CurrentThread.Name, obj.Content));
                }
            }
        }
    }
}